<template>
  <div>
    <div class="tab">
      <div class="tag active" @click="currentMethod(1)">碳排放量</div>
      <span class="hr">/</span>
      <div class="tag" @click="currentMethod(2)">碳排放范围</div>
    </div>
    <ul class="Panel_box scrollbar" v-show="currentView == 2">
      <li class="Panel_box_column scrollbar" v-for="(item,index) in mockData1" :key="index">
        <!-- left_radius -->
        <div class="header">{{item.name}}</div>
        <div class="emission">CO2：{{item.co2}}</div>
        <ul class="panel_list scrollbar">
          <li v-for="(k,v) in item.data" :key="v">
            <div>
              <div class="name_box">
                <div>
                  {{k.name}}
                  <i class="iconfont icon-bg-info" @click="info"></i>
                </div>
              </div>
              <div class="position">{{k.place}}</div>
              <div class="date">{{k.date}}</div>
            </div>
            <div class="co2">
              <div class="val">{{k.num}}</div>
              <div class="name">二氧化碳排放量</div>
            </div>
          </li>
        </ul>
      </li>
    </ul>
    <!-- <div v-if="currentView == 2" style="width: 100%;height:100%">
      <div id="main5" style="width: 100%;height:400px"></div>
    </div>-->
    <ul class="Panel_box scrollbar" v-show="currentView == 1">
      <li class="Panel_box_column scrollbar" v-for="(item,index) in mockData" :key="index">
        <!-- left_radius -->
        <div class="header">{{item.name}}</div>
        <div class="emission">CO2：{{item.co2}}</div>
        <ul class="panel_list scrollbar">
          <li v-for="(k,v) in item.data" :key="v">
            <div>
              <div class="name_box">
                <div>
                  {{k.name}}
                  <i class="iconfont icon-bg-info" @click="info"></i>
                </div>
              </div>
              <div class="position">{{k.place}}</div>
              <div class="date">{{k.date}}</div>
            </div>
            <div class="co2">
              <div class="val">{{k.num}}</div>
              <div class="name">二氧化碳排放量</div>
            </div>
          </li>
        </ul>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currentView: 1,
      mockData: [
        {
          name: "燃料燃烧消耗量",
          co2: "123647",
          data: [
            {
              name: "通勤客车1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 162
            },
            {
              name: "通勤客车2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "通勤客车3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "通勤客车4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "通勤客车5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            }
          ]
        },
        {
          name: "脱硫过程使用量",
          co2: "1247",
          data: [
            {
              name: "化工1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 162
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            }
          ]
        },
        {
          name: "净购入电力热力",
          co2: "236",
          data: [
            {
              name: "空调1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 16
            },
            {
              name: "空调2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96.6
            },
            {
              name: "空调3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 21
            },
            {
              name: "空调4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96
            },
            {
              name: "空调5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 6
            }
          ]
        },
        {
          name: "脱硫过程使用量",
          co2: "1247",
          data: [
            {
              name: "化工1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 162
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            }
          ]
        },
        {
          name: "净购入电力热力",
          co2: "236",
          data: [
            {
              name: "空调1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 16
            },
            {
              name: "空调2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96.6
            },
            {
              name: "空调3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 21
            },
            {
              name: "空调4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96
            },
            {
              name: "空调5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 6
            }
          ]
        }
      ],
      mockData1: [
        {
          name: "范围一 : 直接排放",
          co2: "123647",
          data: [
            {
              name: "通勤客车1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 162
            },
            {
              name: "通勤客车2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "通勤客车3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "通勤客车4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "通勤客车5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            }
          ]
        },
        {
          name: "范围二 : 直接排放",
          co2: "1247",
          data: [
            {
              name: "化工1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 162
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            },
            {
              name: "化工2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 996.6
            },
            {
              name: "化工3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 214
            },
            {
              name: "化工4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 3396
            },
            {
              name: "化工5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 136
            }
          ]
        },
        {
          name: "范围三 : 气体间接排放",
          co2: "236",
          data: [
            {
              name: "空调1",
              place: "新技术园区",
              date: "2022/12/19",
              num: 16
            },
            {
              name: "空调2",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96.6
            },
            {
              name: "空调3",
              place: "新技术园区",
              date: "2022/12/19",
              num: 21
            },
            {
              name: "空调4",
              place: "新技术园区",
              date: "2022/12/19",
              num: 96
            },
            {
              name: "空调5",
              place: "新技术园区",
              date: "2022/12/19",
              num: 6
            }
          ]
        }
      ]
    };
  },
  watch: {
    currentView(val) {
      if (this.currentView == 2) {
        setTimeout(() => {
          this.drawChart5();
        }, 100);
      }
    }
  },

  methods: {
    drawChart5() {
      let myChart1 = this.$echarts.init(document.getElementById("main5"));
      var option = {
        title: {
          text: "碳排放量"
        },
        tooltip: {
          trigger: "axis"
        },
        legend: {
          data: ["燃料燃烧消耗量", "脱硫过程使用量", "净购入电力热力"]
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        },
        yAxis: {
          type: "value"
        },
        series: [
          {
            name: "燃料燃烧消耗量",
            type: "line",
            stack: "Total",
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: "脱硫过程使用量",
            type: "line",
            stack: "Total",
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: "净购入电力热力",
            type: "line",
            stack: "Total",
            data: [150, 232, 201, 154, 190, 330, 410]
          }
        ]
      };
      myChart1.setOption(option);
    },
    info() {},
    currentMethod(val) {
      this.currentView = val;
    }
  }
};
</script>

<style lang="scss">
@import "@/assets/css/dataInsight.scss";
@import "@/assets/css/scrollbar.scss";
</style>